import json

if __name__ == "__main__":
    files = ['train', 'dev', 'test']
    ch_path = 'corpus.ch'
    jp_path = 'corpus.jp'
    ch_lines = []
    jp_lines = []

    for file in files:
        corpus = json.load(open('./json/' + file + '.json', 'r'))
        for item in corpus:
            ch_lines.append(item[0] + '\n')
            jp_lines.append(item[1] + '\n')

    with open(ch_path, "w") as fch:
        fch.writelines(ch_lines)

    with open(jp_path, "w") as fen:
        fen.writelines(jp_lines)


    print("lines of Chinese: ", len(ch_lines))
    print("lines of Japanese: ", len(jp_lines))
    print("-------- Get Corpus ! --------")
